/* Copyright (c) 2006 Nordic Semiconductor. All Rights Reserved.
 *
 * The information contained herein is confidential property of 
 * Nordic Semiconductor. The use, copying, transfer or disclosure of such
 * information is prohibited except by express written agreement with 
 * Nordic Semiconductor.
 */

/** @file
 * USB interface functions for the application
 */

/** @defgroup nordic_usb USB
@{
This module contains, together with the USB HAL, all the code related to the
USB device hardware. In the USB module code you will find:
 - USB descriptors: device descriptors, report descriptors, string descriptors
 - USB interface functions used by the top level firmware application
 - Data structures used for USB reports
 .

The module also contains the code for the callback functions demanded by the
USB HAL, and configures the endpoints used by the firmware.
 */

#ifndef USB_API_H__
#define USB_API_H__

#include <stdint.h>

#define USB_EP_MOUSE 1
#define USB_EP_KEYBOARD 2
#define USB_EP_REMOTE 3

typedef enum
{
 USB_AWAKE,
 USB_REM_WU_ENABLE,
 USB_REM_WU_DISABLE,
} usb_state_t;

void usb_init(void);

/** Initiates a remote wakeup of the USB Host.
 * This is a wrapper function for #hal_usb_wakeup
 */
void usb_wakeup(void);

usb_state_t usb_get_state();

/** Checks the USB wakeup status.
 * The check is perforemed on the Host Wakeup status bit.
 * @return The host has woken up (true or false)
 */
bool usb_has_woken(void);

/** Waits for the USB interface to be configured.
 * Calling this function will halt the program and wait until the USB interface
 * goes into the CONFIGURED state.
 */
void usb_wait_for_configuration(void);

/** Sends data to the host.
 * @param in_data Pointer to the buffer containg data to send
 * @param ep_num IN endpoint number
 * @param size Buffer size in bytes
 */
void usb_send_packet(uint8_t* in_data, uint8_t ep_num, uint8_t size);

#endif // USB_API_H__

/** @} */
